package com.aceleeyy.apb.base;

import org.springframework.web.bind.annotation.*;

/**
 * 消费者-接口基础类
 *
 * @author Ace Lee
 * @version 1.0
 * @date 2020/8/10 10:34
 **/
public interface BaseService<T extends BaseModel> {

    /**
     * 列表
     *
     * @param baseUri
     * @return
     */
    @GetMapping("{baseUri}")
    Object getList(@PathVariable String baseUri,
                   @RequestParam(value = "isPage", required = false) Boolean isPage,
                   @RequestParam(value = "attributes", required = false) String attributes,
                   @RequestParam(value = "filters", required = false) String filters,
                   @RequestParam(value = "orders", required = false) String orders,
                   @RequestParam(value = "skip", required = false) Integer skip,
                   @RequestParam(value = "top", required = false) Integer top);

    /**
     * 查看
     *
     * @param baseUri
     * @param id
     * @return
     */
    @GetMapping("{baseUri}"+"/{id}")
    T getOne(@PathVariable String baseUri, @PathVariable("id") Long id);

    /**
     * 新增
     *
     * @param baseUri
     * @param entity
     * @return
     */
    @PostMapping("{baseUri}")
    boolean addOne(@PathVariable String baseUri, T entity);

    /**
     * 更新
     *
     * @param baseUri
     * @param id
     * @param entity
     * @return
     */
    @PutMapping("{baseUri}"+"/{id}")
    boolean editOne(@PathVariable String baseUri, @PathVariable("id") Long id, @RequestBody T entity);

    /**
     * 删除
     *
     * @param baseUri
     * @param id
     * @return
     */
    @DeleteMapping("{baseUri}"+"/{id}")
    boolean delOne(@PathVariable String baseUri, @PathVariable("id") Long id);

}
